<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>

<div class="page-title"> 
    <h1><?php echo $this->__('Product Return #%s', $this->getRma()->getrma_ref()) ?></h1> 
</div> 

<form method="POST" id="edit_form" name="edit_form" action="<?php echo $this->getSubmitUrl(); ?>">
<input type="hidden" id="data[rma_id]" name="data[rma_id]" value="<?php echo $this->getRma()->getId(); ?>">
<input type="hidden" id="data[rma_order_id]" name="data[rma_order_id]" value="<?php echo $this->getRma()->getSalesOrder()->getId(); ?>">
<input type="hidden" id="data[rma_customer_id]" name="data[rma_customer_id]" value="<?php echo $this->getRma()->getrma_customer_id(); ?>">
<input type="hidden" id="data[rma_ref]" name="data[rma_ref]" value="<?php echo $this->getRma()->getrma_ref(); ?>">
<input name="form_key" type="hidden" value="<?php echo $this->getFormKey() ?>" />
<div class="fieldset"> 
        <h2 class="legend"><?php echo $this->__('Main Information'); ?></h2> 
        
		<?php if($this->CustomerCanEdit()): ?>
	        	<table cellspacing="0" class="form-list">
	                <tr>
	                    <td class="label" width="150"><?php echo $this->__('Phone'); ?></td>
	                    <td class="input-ele"><input type="text" name="data[rma_customer_phone]" id="data[rma_customer_phone]" value="<?php echo $this->getRma()->getrma_customer_phone(); ?>"></td>
	                </tr>
	                <tr>
	                    <td class="label"><?php echo $this->__('Email'); ?></td>
	                    <td class="input-ele"><input type="text" name="data[rma_customer_email]" id="data[rma_customer_email]" value="<?php echo $this->getRma()->getrma_customer_email(); ?>"></td>
	                </tr>
	                <tr>
	                    <td class="label"><?php echo $this->__('Address'); ?></td>
	                    <td class="input-ele"><?php echo $this->getCustomerAddressesAsCombo('data[rma_address_id]', $this->getRma()->getrma_address_id()); ?></td>
	                </tr>
	           </table>
	      <?php else: ?>
	      		<table cellspacing="0" class="form-list">
	                <tr>
	                    <td class="label"><?php echo $this->__('Status'); ?></td>
	                    <td class="input-ele"><?php echo $this->__($this->getRma()->getrma_status()); ?></td>
	                </tr>
	                <tr>
	                    <td class="label" width="150"><?php echo $this->__('Phone'); ?></td>
	                    <td class="input-ele"><?php echo $this->getRma()->getrma_customer_phone(); ?></td>
	                </tr>
	                <tr>
	                    <td class="label"><?php echo $this->__('Email'); ?></td>
	                    <td class="input-ele"><?php echo $this->getRma()->getrma_customer_email(); ?></td>
	                </tr>
	                <tr>
	                    <td class="label"><?php echo $this->__('Address'); ?></td>
						<?php //todo : check the use of getrma_address_id ?>
	                    <td class="input-ele"><?php echo $this->getCustomerAddresses($this->getRma()->getrma_address_id()); ?></td>
	                </tr>
	           </table>	      
	      <?php endif; ?>
</div>
	<div class="fieldset"> 
        <h2 class="legend"><?php echo $this->__('Products'); ?></h2> 
		<table cellspacing="0" class="data-table" id="my-orders-table">
			<thead> 
                <tr class="headings"> 
	            	<th><span class="nobr"><?php echo $this->__('Product'); ?></span></th> 
	            	<th><span class="nobr"><?php echo $this->__('Qty'); ?></span></th> 
	            	<th><span class="nobr"><?php echo $this->__('Reason'); ?></span></th> 
	            	<th><span class="nobr"><?php echo $this->__('Comments'); ?></span></th> 
	            </tr>
	        </thead>
	        <tbody>
	        		<?php foreach($this->getRma()->getProducts() as $product): ?>
	    	        	<tr>
   	        				<?php if ($product->getrp_qty() > 0): ?>
	    	        			<td><?php echo $this->getProductName($product); ?></td>
	    	        		 	<td class="a-center"><?php echo $product->getrp_qty(); ?></td>
	    	        		 	<td class="a-center"><?php echo $this->__($product->getrp_reason()); ?></td>
	    	        			<td class="a-center"><?php echo $product->getrp_description(); ?></td>
	    	        		<?php endif; ?>
    	        	</tr>
   	        		<?php endforeach; ?>
	        </tbody>
		</table>
</div>   

<div class="fieldset"> 
        <h2 class="legend"><?php echo $this->__('Comments'); ?></h2> 
        
		<?php echo $this->getRma()->getrma_public_description(); ?>
</div>

    <div class="button-set">  
		<center>
        <?php if($this->getRma()->getrma_status() == 'product_return_accepted'): ?>
        	<button type="button" class="button" onclick="document.location.href='<?php echo $this->getReturnCGVUrl(); ?>';"><span><span><?php echo $this->__('Print Product Return Form'); ?></span></span></button> 
        <?php endif;?> 	
		</center>
    </div> 

</form>
